#pragma once

#include <robot_chassis/CTurnOnRobot.hpp>
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/battery_state.hpp>

/**
 * @brief 电池电压节点，负责发布电池状态
 * 
 * 从STM32获取电池电压数据，发布到标准的 /chassis/battery_state 话题
 */
class CRobotVoltage : public rclcpp::Node
{
  public:
    CRobotVoltage(const std::string& nodeName);
    ~CRobotVoltage();

  private:
    void getVoltage();
    void callback();

    rclcpp::TimerBase::SharedPtr                                 timer_;
    rclcpp::Publisher<sensor_msgs::msg::BatteryState>::SharedPtr pub_;
    CTurnOnRobot&                                                turnonRobot_;
    sensor_msgs::msg::BatteryState                               sensorBatteryData_;
    float                                                        voltageValue_;

    // 电池参数
    float fullVoltage_{12.6f};  // 满电电压
    float lowVoltage_{10.0f};   // 低电压
};
